# /**
# * Copyright (c) 2022 Beijing Jiaotong University
# * PhotLab is licensed under [Open Source License].
# * You can use this software according to the terms and conditions of the [Open Source License].
# *
# * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
# *
# * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# *
# * See the [Open Source License] for more details.
# */
# /**
# * Author: Shihao Xie
# * Created: Feb. 4, 2022
# * Supported by: National Key Research and Development Program of China
# */

from phot_server.core.api_injector import api
from phot_server.rpc.remote_service.Remote import Processor


class RemoteService:
    """
    该服务是计算图相关服务，可以通过这个服务管理用户拥有的计算图。
    调用该服务前，请确认已经做过连接服务相关操作并成功连接。例如：

    Examples:
        >>> from thrift import Thrift
        >>> from thrift.transport import TSocket
        >>> from thrift.transport import TTransport
        >>> from thrift.protocol import TBinaryProtocol
        >>> from photlab.remote_service.Remote import Client as remote_client
        >>> transport = TSocket.TSocket("localhost", 8080)
        >>> transport_protocol = TTransport.TBufferedTransport(transport)
        >>> protocol_factory = TBinaryProtocol.TBinaryProtocol(transport_protocol)
        >>> remote_client = remote_client(protocol_factory)
        >>> transport.open()

    具体使用可以查看测试用例 test/test_interface/test_library.py
    """

    def __init__(self):
        print("hello world!")

    @api(Processor.process_ping)
    def ping(self, stime):
        """
        接口未完成

        服务端打开一个仿真网格，加载计算图的数据并生成一个仿真网格模型(PhotGraph)。

        Args:
            stime (long): 仿真网格的路径

        Returns:
            long:

        Raises:
            PhotError: 异常代码查看PhotError的exception_code

        Examples:
            >>> remote_client.ping(100)
        """
        # return time.time() - stime
        return stime
